<template>
	<view style="margin-left: 3%;margin-top: 2%; width: 94%;">
		<view v-for="approval in approvalList" :key="approval.id" style="width: 100%; border-bottom: 1rpx solid #a6a6a6 ;padding-bottom: 4%;" @click="navTo('/pages/workbench/approval',approval.id)">
			<view style="display:flex; padding: 2%; font-size: 30rpx;" >
				<view >
					<u-avatar
					size="30"
					:text="getAvatar(approval)"
					shape="square" 
					bg-color="#0080FF"
					font-size='13'
					:src="approval.avaUrl"
					>
					</u-avatar>
				</view>
				<view style="width: 91%;padding-top: 1%;">
					<text style="margin-left: 2%; font-weight: 600;">{{approval.userName}}提交的学生请假审批单</text>
					<text style="font-size: 25rpx; margin-left: 10%;color:#b2b2b3 ;">2023-12-12</text>
				</view>
			</view>
			<view style="font-size: 27rpx;padding-left: 2%;margin-top: 1% ;color: #b2b2b3;">
				<text>姓名:{{approval.userName}}</text>
			</view>
			<view style="font-size: 27rpx;padding-left: 2%; color: #b2b2b3;">
				<text>学校:玉林师范学院</text>
			</view>
			<view style="font-size: 27rpx;padding-left: 2%;margin-top: 1%; color: #b2b2b3;">
				<text>{{approval.result===0?'审批中':'审批完成'}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				approvalList:[],
			}
		},
		methods: {
			navTo(url,id){
				uni.navigateTo({
					url:url+'?id='+id
				})
			},
			getAvatar(approval){
				let text = '';
				if(approval.userName === null){
					approval.userName = "";
				}
				if(approval.avaUrl == null|| approval.avaUrl.length == 0){
					text = approval.userName.slice(-2);
				}else{
					text = null;
				}
				return text;
			},
			
		},
		onLoad() {
			uni.request({
				url:'http://localhost:8090/nailCampus/approval/getUserApproval',
				method:'GET',
				header:{
					"token":uni.getStorageSync('token')
				},
				success:res=>{
					this.approvalList = res.data.data
					console.log(res.data.data)
				}
			})
		}
	}
</script>

<style>

</style>
